#include "data.h"

Data::Data(){
    filepath = NULL;
    addTags();
}

Data::Data(char *_filepath) : filepath(_filepath){
    addTags();
    setWeights();
}


void Data::addTags(){
    tags.push_back("def-instance");
    tags.push_back("DEF-INSTANCE");
    tags.push_back("location");
    tags.push_back("LOCATION");
    tags.push_back("state");
    tags.push_back("STATE");
    tags.push_back("control");
    tags.push_back("CONTROL");
    tags.push_back("no-of-students thous:");
    tags.push_back("NO-OF-STUDENTS THOUS:");
    tags.push_back("male:female ratio:");
    tags.push_back("MALE:FEMALE RATIO:");
    tags.push_back("student:faculty ratio:");
    tags.push_back("STUDENT:FACULTY RATIO:");
    tags.push_back("sat verbal");
    tags.push_back("SAT VERBAL");
    tags.push_back("sat math");
    tags.push_back("SAT MATH");
    tags.push_back("expenses thous$:");
    tags.push_back("EXPENSES THOUS$:");
    tags.push_back("percent-financial-aid");
    tags.push_back("PERCENT-FINANCIAL-AID");
    tags.push_back("no-applicants thous:");
    tags.push_back("NO-APPLICANTS THOUS:");
    tags.push_back("percent-admittance");
    tags.push_back("PERCENT-ADMITTANCE");
    tags.push_back("percent-enrolled");
    tags.push_back("PERCENT-ENROLLED");
    tags.push_back("academics scale:1-5");
    tags.push_back("ACADEMICS SCALE:1-5");
    tags.push_back("social scale:1-5");
    tags.push_back("SOCIAL SCALE:1-5");
    tags.push_back("quality-of-life scale:1-5");
    tags.push_back("QUALITY-OF-LIFE SCALE:1-5");
    tags.push_back("academic-emphasis");
    tags.push_back("ACADEMIC-EMPHASIS");

}

void Data::read1(){
    if(!filepath) return;
    cout<<"path:"<<filepath<<endl;
    ifstream file(filepath);
    if(!file.is_open()) return;

    cout<<"OTWARTO!"<<endl;
    string temp;
   // file >> temp;
   //

  std::vector<string> record;
   while(!file.eof()){
  //  for(int n = 0 ; n < 20 ; n++){
        getline(file,temp);
        size_t end=0;
        size_t place=-1;
        for(int i = 0 ; i < tags.size() ; ++i){
            //if(i == 0) end=0;
            //if(i > 2 && i < tags.size()-2) end=5;
            place = temp.find(tags[i]);
            if(place < 100) {
                if(i < tags.size() -2) record.push_back(temp.substr(place+tags[i].size(), temp.size()-tags[i].size()-end));
                if(i == tags.size() - 1 || i == tags.size() - 2){
                   // getline(file,temp);
                    place = -1;
                    place = temp.find(tags[i]);
                    if(place > 1000) continue;

                    while(place < 100){
                       record.push_back(temp.substr(place+tags[i].size(), temp.size()-tags[i].size()-end));
                       getline(file,temp);
                       place = temp.find(tags[i]);
                    }
                  records.push_back(record);
                  record.clear();

                  place = temp.find(tags[0]);
                  if(place > 1000) place = temp.find(tags[1]);
                //  cout<<temp<<endl;
                  if(place < 100) record.push_back(temp.substr(place+tags[0].size(), temp.size()-tags[0].size()));
                  break;
                }
            }

        }


    }
for(int j = 0 ; j < records.size() ; ++ j)
  //  for(int i = 0 ; i < records[j].size(); ++i){
        cout<<records[j][0]<<endl;
   // }
    removeBrackets();
}

void Data::read2(){
    if(!filepath) return;
    cout<<"path:"<<filepath<<endl;
    ifstream file(filepath);

    if(!file.is_open()) {
        return;
    }

    if(!file.is_open()) {
        cout<<"Nie otwarto pliku!"<<endl;
        return;
    }

    cout<<"OTWARTO!"<<endl;
    string temp;

    while(!file.eof()){
        getline(file,temp);
        stringvec vec;
        size_t przecinekPos=0,poprzedni=0;
        for(int i = 0 ; i < temp.length() ; ++i){
            string wyraz;

            //znajdz wyraz do przecinka
            przecinekPos = temp.find(",",poprzedni+1);

            if(przecinekPos==string::npos) break;

            //wez wyraz
            wyraz = temp.substr(poprzedni,przecinekPos-poprzedni);
            poprzedni = przecinekPos;

            // wywal ostatnie puste miejsca
            if(vec.size() > 17 && wyraz.length() < 5) continue;

            //dodaj wyraz
            vec.push_back(wyraz);

        }

        records.push_back(vec);

    }
    removeComas();
    removeSpaces();
    lowerLetters();



}

void Data::save(char *pathToFile){
    ofstream file(pathToFile);

    for(int i = 0 ; i < records.size() ; ++i){
        for(int j = 0 ; j < records[i].size(); ++j){
            if(records[i][j].size() < 2 )continue;
            file << records[i][j];
            if(j != records[i].size()-1) file<<", ";
        }
        file << "\r\n";
    }


}

void Data::lowerLetters(){
    for(int i = 0 ; i < records.size() ; ++i){
        for(int j = 0 ; j < records[i].size(); ++j){
            char c;
            for(int k = 0 ; k < records[i][j].length(); ++k){
                c=records[i][j][k];
                records[i][j][k] = tolower(c);
            }
        }
    }

}

void Data::removeComas(){
    for(int i = 0 ; i < records.size() ; ++ i)
        for (int j = 0; j < records[i].size(); ++j) {
            size_t bracketPos = records[i][j].find(",");
            if(bracketPos!=string::npos)
                records[i][j].erase(bracketPos, 1);

        }
}

void Data::removeBrackets(){
    for(int i = 0 ; i < records.size() ; ++ i)
        for (int j = 0; j < records[i].size(); ++j) {
            size_t bracketPos = records[i][j].find(")");
            if(bracketPos!=string::npos)
                records[i][j].erase(records[i][j].begin() + bracketPos, records[i][j].end());

        }
}
 void Data::removeSpaces(){
     for(int i = 0 ; i < records.size() ; ++ i)
         for (int j = 0; j < records[i].size(); ++j) {
             size_t bracketPos = records[i][j].find(" ");
             if(bracketPos!=string::npos)
                 records[i][j].erase(bracketPos, 1);

         }
 }

 vector< vector<float> > Data::getNumericalData(){
     vector< vector<float> > numvec(records.size());
    srand( time(NULL ));
    // cout<<records[records.size()-2][0]<<endl;

    //Stany
    for(int i = 0 ; i < records.size() ; ++i){
        vector< float > tempvec(13);
    // if(records[i].size()>0) cout<<"TEMP="<<records[i][0]<<" i="<<i<<endl;
        if(records[i].size()>1 && records[i][1].find("alabama")!=string::npos) tempvec[1] = 0 * weights[0];
        if(records[i].size()>1 && records[i][1].find("alaska")!=string::npos)  tempvec[1] = 1 * weights[0];
        if(records[i].size()>1 && records[i][1].find("arizona")!=string::npos) tempvec[1] = 2 * weights[0];
        if(records[i].size()>1 && records[i][1].find("arkansas")!=string::npos) tempvec[1] = 3 * weights[0];
        if(records[i].size()>1 && records[i][1].find("connecticut")!=string::npos) tempvec[1] = 4 * weights[0];
        if(records[i].size()>1 && records[i][1].find("southdakota")!=string::npos) tempvec[1] = 5 * weights[0];
        if(records[i].size()>1 && records[i][1].find("northdakota")!=string::npos) tempvec[1] = 6 * weights[0];
        if(records[i].size()>1 && records[i][1].find("delaware")!=string::npos) tempvec[1] = 7 * weights[0];
        if(records[i].size()>1 && records[i][1].find("florida")!=string::npos) tempvec[1] = 8 * weights[0];
        if(records[i].size()>1 && records[i][1].find("alabama")!=string::npos) tempvec[1] = 9 * weights[0];

        if(records[i].size()>1 && records[i][1].find("georgia")!=string::npos) tempvec[1] = 10 * weights[0];
        if(records[i].size()>1 && records[i][1].find("hawaii")!=string::npos) tempvec[1] = 11 * weights[0];
        if(records[i].size()>1 && records[i][1].find("idaho")!=string::npos) tempvec[1] = 12 * weights[0];
        if(records[i].size()>1 && records[i][1].find("illinois")!=string::npos) tempvec[1] = 13 * weights[0];
        if(records[i].size()>1 && records[i][1].find("indiana")!=string::npos) tempvec[1] = 14 * weights[0];
        if(records[i].size()>1 && records[i][1].find("iowa")!=string::npos) tempvec[1] = 15 * weights[0];
        if(records[i].size()>1 && records[i][1].find("kansas")!=string::npos) tempvec[1] = 16 * weights[0];
        if(records[i].size()>1 && records[i][1].find("southcarolina")!=string::npos) tempvec[1] = 17 * weights[0];
        if(records[i].size()>1 && records[i][1].find("northcarolina")!=string::npos) tempvec[1] = 18 * weights[0];
        if(records[i].size()>1 && records[i][1].find("kentucky")!=string::npos) tempvec[1] = 19 * weights[0];

        if(records[i].size()>1 && records[i][1].find("colorado")!=string::npos) tempvec[1] = 20 * weights[0];
        if(records[i].size()>1 && records[i][1].find("lousiana")!=string::npos) tempvec[1] = 21 * weights[0];
        if(records[i].size()>1 && records[i][1].find("kentucky")!=string::npos) tempvec[1] = 22 * weights[0];
        if(records[i].size()>1 && records[i][1].find("maine")!=string::npos) tempvec[1] = 23 * weights[0];
        if(records[i].size()>1 && records[i][1].find("maryland")!=string::npos) tempvec[1] = 24 * weights[0];
        if(records[i].size()>1 && records[i][1].find("massachusetts")!=string::npos) tempvec[1] = 25 * weights[0];
        if(records[i].size()>1 && records[i][1].find("michigan")!=string::npos) tempvec[1] = 26 * weights[0];
        if(records[i].size()>1 && records[i][1].find("minnesota")!=string::npos) tempvec[1] = 27 * weights[0];
        if(records[i].size()>1 && records[i][1].find("mississippi")!=string::npos) tempvec[1] = 28 * weights[0];
        if(records[i].size()>1 && records[i][1].find("missouri")!=string::npos) tempvec[1] = 29 * weights[0];
        if(records[i].size()>1 && records[i][1].find("montana")!=string::npos) tempvec[1] = 30 * weights[0];

        if(records[i].size()>1 && records[i][1].find("nebraska")!=string::npos) tempvec[1] = 31 * weights[0];
        if(records[i].size()>1 && records[i][1].find("nevada")!=string::npos) tempvec[1] = 32 * weights[0];
        if(records[i].size()>1 && records[i][1].find("newhampshire")!=string::npos) tempvec[1] = 33 * weights[0];
        if(records[i].size()>1 && records[i][1].find("newjersey")!=string::npos) tempvec[1] = 34 * weights[0];
        if(records[i].size()>1 && records[i][1].find("newyork")!=string::npos) tempvec[1] = 35 * weights[0];
        if(records[i].size()>1 && records[i][1].find("newmexico")!=string::npos) tempvec[1] = 36 * weights[0];
        if(records[i].size()>1 && records[i][1].find("ohio")!=string::npos) tempvec[1] = 37 * weights[0];
        if(records[i].size()>1 && records[i][1].find("oklahoma")!=string::npos) tempvec[1] = 38 * weights[0];
        if(records[i].size()>1 && records[i][1].find("oregon")!=string::npos) tempvec[1] = 39 * weights[0];
        if(records[i].size()>1 && records[i][1].find("pennsylvania")!=string::npos) tempvec[1] = 40 * weights[0];

        if(records[i].size()>1 && records[i][1].find("rhodeisland")!=string::npos) tempvec[1] = 41 * weights[0];
        if(records[i].size()>1 && records[i][1].find("texas")!=string::npos) tempvec[1] = 42 * weights[0];
        if(records[i].size()>1 && records[i][1].find("tennessee")!=string::npos) tempvec[1] = 43 * weights[0];
        if(records[i].size()>1 && records[i][1].find("utah")!=string::npos) tempvec[1] = 44 * weights[0];
        if(records[i].size()>1 && records[i][1].find("vermont")!=string::npos) tempvec[1] = 45 * weights[0];
        if(records[i].size()>1 && records[i][1].find("Washington")!=string::npos) tempvec[1] = 46 * weights[0];
        if(records[i].size()>1 && records[i][1].find("virginia")!=string::npos) tempvec[1] = 47 * weights[0];
        if(records[i].size()>1 && records[i][1].find("westvirginia")!=string::npos) tempvec[1] = 48 * weights[0];
        if(records[i].size()>1 && records[i][1].find("wisconsin")!=string::npos) tempvec[1] = 49 * weights[0];
        if(records[i].size()>1 && records[i][1].find("wyoming")!=string::npos) tempvec[1] = 50 * weights[0];

        numvec[i] = tempvec;
    }

    //lokalizacja
    for(int i = 0 ; i < records.size() ; ++i){
        if(records[i].size()>2 && records[i][2].find("city")!=string::npos)     numvec[i][2] = 0 * weights[1];
        else if(records[i].size()>2 && records[i][2].find("suburban")!=string::npos) numvec[i][2] = 1 * weights[1];
        else if(records[i].size()>2 && records[i][2].find("small-city")!=string::npos) numvec[i][2] = 2 * weights[1];
        else if(records[i].size()>2 && records[i][2].find("small-town")!=string::npos) numvec[i][2] = 2 * weights[1];
        else numvec[i][2] = rand() % 3; // random
    }

    //wladze
     for(int i = 0 ; i < records.size() ; ++i){
         if(records[i].size()>3 && records[i][3].find("private")!=string::npos)     numvec[i][3] = 0 * weights[2];
         else if(records[i].size()>3 && records[i][3].find("public")!=string::npos) numvec[i][3] = 1 * weights[2];
         else if(records[i].size()>3 && records[i][3].find("state")!=string::npos)  numvec[i][3] = 2 * weights[2];
         else numvec[i][3] = rand() % 2; // random
     }

     //ilosc studentow
     for(int i = 0 ; i < records.size() ; ++i){
         if(records[i].size()>4 && records[i][4].find("5-")!=string::npos)          numvec[i][4] = 0 * weights[3];
         else if(records[i].size()>4 && records[i][4].find("5-10")!=string::npos)   numvec[i][4] = 1 * weights[3];
         else if(records[i].size()>4 && records[i][4].find("10-15")!=string::npos)  numvec[i][4] = 2 * weights[3];
         else if(records[i].size()>4 && records[i][4].find("15-20")!=string::npos)  numvec[i][4] = 3 * weights[3];
         else if(records[i].size()>4 && records[i][4].find("20+")!=string::npos)    numvec[i][4] = 4 * weights[3];
         else numvec[i][4] = rand() % 4; // random
     }

    //stosunek M-K
    for(int i = 0 ; i < records.size() ; ++i){
         if(records[i].size()>5 && records[i][5].find("30:70")!=string::npos)     numvec[i][5] = 0 * weights[4];
         else if(records[i].size()>5 && records[i][5].find("40:60")!=string::npos) numvec[i][5] = 1 * weights[4];
         else if(records[i].size()>5 && records[i][5].find("50:50")!=string::npos)  numvec[i][5] = 2 * weights[4];
         else if(records[i].size()>5 && records[i][5].find("60:40")!=string::npos)  numvec[i][5] = 3 * weights[4];
         else numvec[i][5] = rand() % 3; // random
    }

    //srednie wydatki na studiach // pos9
    for(int i = 0 ; i < records.size() ; ++i){
         if(records[i].size()>9 && records[i][9].find("4-")!=string::npos)          numvec[i][6] = 0 * weights[5];
         else if(records[i].size()>9 && records[i][9].find("5-")!=string::npos)     numvec[i][6] = 1 * weights[5];
         else if(records[i].size()>9 && records[i][9].find("7-10")!=string::npos)   numvec[i][6] = 2 * weights[5];
         else if(records[i].size()>9 && records[i][9].find("10+")!=string::npos)    numvec[i][6] = 3 * weights[5];
         else numvec[i][6] = rand() % 3; // random
    }

    //procent finansowanych //pos10
    for(int i = 0 ; i < records.size() ; ++i){
         if(records[i].size()>10 && records[i][7].find("4-")!=string::npos)       numvec[i][7] = 0 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("0")!=string::npos)  numvec[i][7] = 1 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("5")!=string::npos)  numvec[i][7] = 2 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("10")!=string::npos) numvec[i][7] = 3 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("15")!=string::npos) numvec[i][7] = 4 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("20")!=string::npos) numvec[i][7] = 5 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("25")!=string::npos) numvec[i][7] = 6 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("30")!=string::npos) numvec[i][7] = 7 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("35")!=string::npos) numvec[i][7] = 8 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("40")!=string::npos) numvec[i][7] = 9 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("50")!=string::npos) numvec[i][7] = 10 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("55")!=string::npos) numvec[i][7] = 11 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("60")!=string::npos) numvec[i][7] = 12 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("65")!=string::npos) numvec[i][7] = 13 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("70")!=string::npos) numvec[i][7] = 14 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("75")!=string::npos) numvec[i][7] = 15 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("80")!=string::npos) numvec[i][7] = 16 * weights[6];
         else if(records[i].size()>10 && records[i][10].find("85")!=string::npos) numvec[i][7] = 17 * weights[6];
         else numvec[i][7] = rand() % 17; // random
    }

    //liczba aplikujacych // pos 11
    for(int i = 0 ; i < records.size() ; ++i){
        if(records[i].size()> 11 && records[i][11].find("4-")!=string::npos)            numvec[i][8] = 0 * weights[7];
        else if(records[i].size()>11 && records[i][11].find("4-7")!=string::npos)       numvec[i][8] = 1 * weights[7];
        else if(records[i].size()>11 && records[i][11].find("7-10")!=string::npos)      numvec[i][8] = 2 * weights[7];
        else if(records[i].size()>11 && records[i][11].find("10-13")!=string::npos)     numvec[i][8] = 3 * weights[7];
        else if(records[i].size()>11 && records[i][11].find("13-17")!=string::npos)     numvec[i][8] = 4 * weights[7];
        else if(records[i].size()>11 && records[i][11].find("17+")!=string::npos)       numvec[i][8] = 5 * weights[7];
        else numvec[i][8] = rand() % 5; // random
        //cout<<records[i][11]<<endl;
    }

    //procent przyjetych // pos 13
    for(int i = 0 ; i < records.size() ; ++i){
         if(records[i].size()>13 && records[i][13].find("30")!=string::npos)      numvec[i][9] = 0 * weights[8];
         else if(records[i].size()>13 && records[i][13].find("35")!=string::npos) numvec[i][9] = 1 * weights[8];
         else if(records[i].size()>13 && records[i][13].find("40")!=string::npos) numvec[i][9] = 2 * weights[8];
         else if(records[i].size()>13 && records[i][13].find("45")!=string::npos) numvec[i][9] = 3 * weights[8];
         else if(records[i].size()>13 && records[i][13].find("50")!=string::npos) numvec[i][9] = 4 * weights[8];
         else if(records[i].size()>13 && records[i][13].find("55")!=string::npos) numvec[i][9] = 5 * weights[8];
         else if(records[i].size()>13 && records[i][13].find("60")!=string::npos) numvec[i][9] = 6 * weights[8];
         else if(records[i].size()>13 && records[i][13].find("65")!=string::npos) numvec[i][9] = 7 * weights[8];
         else if(records[i].size()>13 && records[i][13].find("70")!=string::npos) numvec[i][9] = 8 * weights[8];
         else if(records[i].size()>13 && records[i][13].find("75")!=string::npos) numvec[i][9] = 9 * weights[8];
         else if(records[i].size()>13 && records[i][13].find("80")!=string::npos) numvec[i][9] = 10 * weights[8];
         else if(records[i].size()>13 && records[i][13].find("85")!=string::npos) numvec[i][9] = 11 * weights[8];
         else if(records[i].size()>13 && records[i][13].find("90")!=string::npos) numvec[i][9] = 12 * weights[8];
         else if(records[i].size()>13 && records[i][13].find("95")!=string::npos) numvec[i][9] = 13 * weights[8];
         else numvec[i][9] = rand() % 12; // random
    }

    //jakosc uczelni // pos 14
    for(int i = 0 ; i < records.size() ; ++i){
         if(records[i].size()>14 && records[i][14].find("1")!=string::npos)      numvec[i][10] = 0 * weights[9];
         else if(records[i].size()>14 && records[i][14].find("2")!=string::npos) numvec[i][10] = 1 * weights[9];
         else if(records[i].size()>14 && records[i][14].find("3")!=string::npos) numvec[i][10] = 2 * weights[9];
         else if(records[i].size()>14 && records[i][14].find("4")!=string::npos) numvec[i][10] = 3 * weights[9];
         else if(records[i].size()>14 && records[i][14].find("5")!=string::npos) numvec[i][10] = 4 * weights[9];
         else numvec[i][10] = rand() % 4; // random
    }

    //stypendia // pos 15
    for(int i = 0 ; i < records.size() ; ++i){
         if(records[i].size()>15 && records[i][15].find("1")!=string::npos)      numvec[i][11] = 0 * weights[10];
         else if(records[i].size()>15 && records[i][15].find("2")!=string::npos) numvec[i][11] = 1 * weights[10];
         else if(records[i].size()>15 && records[i][15].find("3")!=string::npos) numvec[i][11] = 2 * weights[10];
         else if(records[i].size()>15 && records[i][15].find("4")!=string::npos) numvec[i][11] = 3 * weights[10];
         else if(records[i].size()>15 && records[i][15].find("5")!=string::npos) numvec[i][11] = 4 * weights[10];
         else numvec[i][11] = rand() % 4; // random
    }

    //jakosc zycia // pos 16
    for(int i = 0 ; i < records.size() ; ++i){
         if(records[i].size()>16 && records[i][16].find("1")!=string::npos)      numvec[i][12] = 0 * weights[11];
         else if(records[i].size()>16 && records[i][16].find("2")!=string::npos) numvec[i][12] = 1 * weights[11];
         else if(records[i].size()>16 && records[i][16].find("3")!=string::npos) numvec[i][12] = 2 * weights[11];
         else if(records[i].size()>16 && records[i][16].find("4")!=string::npos) numvec[i][12] = 3 * weights[11];
         else if(records[i].size()>16 && records[i][16].find("5")!=string::npos) numvec[i][12] = 4 * weights[11];
         else numvec[i][11] = rand() % 4; // random
    }

    //kierunki pos 17
    for(int i = 0 ; i < records.size() ; ++i){
         if(records[i].size()>17 && records[i][17].find("education ")!=string::npos)                        numvec[i][13] = 0 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("art")!=string::npos)                          numvec[i][13] = 1 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("liberal-arts")!=string::npos)                 numvec[i][13] = 2 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("history")!=string::npos)                      numvec[i][13] = 3 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("business-and-management")!=string::npos)      numvec[i][13] = 4 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("law")!=string::npos)                          numvec[i][13] = 5 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("journalism")!=string::npos)                   numvec[i][13] = 6 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("economics")!=string::npos)                    numvec[i][13] = 7 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("NALKIPOLITYCZNE")!=string::npos)              numvec[i][13] = 8 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("communications ")!=string::npos)              numvec[i][13] = 9 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("psychology")!=string::npos)                   numvec[i][13] = 10 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("biology")!=string::npos)                      numvec[i][13] = 11 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("veterinary-medicine")!=string::npos)          numvec[i][13] = 12 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("nursing")!=string::npos)                      numvec[i][13] = 13 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("human-ecology ")!=string::npos)               numvec[i][13] = 14 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("architecture")!=string::npos)                 numvec[i][13] = 15 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("engineering")!=string::npos)                  numvec[i][13] = 16 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("computer-science")!=string::npos)             numvec[i][13] = 17 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("accounting")!=string::npos)                   numvec[i][13] = 18 * weights[12];
         else if(records[i].size()>17 && records[i][17].find("english")!=string::npos)                      numvec[i][13] = 19 * weights[12];
         else numvec[i][11] = rand(); // random
    }



    //test
    for(int j = 0 ; j < numvec.size() ; ++ j){
        for(int i = 0 ; i < numvec[j].size(); ++i){
       //     cout<<numvec[j][i]<<" ";
        }
    //  cout<<endl;
    }

    for(int i = 0 ; i < records.size() ; ++i){
     //  if( records[i].size() > 17)
       // cout<<records[i][17]<<" ";
       //  cout<<numvec[110][i]<<" ";
    }
    cout<<endl;

   // cout<<"SIZE = "<<records[110].size()<<endl;
    //cout<<"SIZE = "<<numvec[110].size()<<endl;
    return numvec;

 }

 stringvec  Data::getRecord(unsigned int i){
    // if(i > this->records.size()) return records[size()-1];
     return records[i];
 }

void Data::setWeights(){

   weights.push_back(0.04f);    // 0 stany
   weights.push_back(1.0f);    // 1 lokalizacja
   weights.push_back(1.0f);     // 2 wladze
   weights.push_back(0.5f);     // 3 ilosc studentow
   weights.push_back(0.666666f);// 4 stosunek M-K
   weights.push_back(0.666666f);// 5 srednie wydatki na studiach
   weights.push_back(0.117647f);// 6 procent finansowanych
   weights.push_back(0.4);      // 7 liczba aplikujacych
   weights.push_back(0.153846f);// 8 procent przyjetych
   weights.push_back(0.5);      // 9 jakosc uczelni
   weights.push_back(0.5);      // 10 stypendia
   weights.push_back(0.5);      // 11 jakosc zycia
   weights.push_back(0.10526f);// 12 kierunek

//   weights.push_back(1);    // 0 stany166666f
//   weights.push_back(1);    // 1 lokalizacja
//   weights.push_back(1);     // 2 wladze
//   weights.push_back(1);     // 3 ilosc studentow
//   weights.push_back(1);     // 4 stosunek M-K
//   weights.push_back(1);     // 5 srednie wydatki na studiach
//   weights.push_back(1);// 6 procent finansowanych
//   weights.push_back(1);      // 7 liczba aplikujacych
//   weights.push_back(1);  // 8 procent przyjetych
//   weights.push_back(1);      // 9 jakosc uczelni
//   weights.push_back(1);      // 10 stypendia
//   weights.push_back(1);      // 11 jakosc zycia
//    weights.push_back(1);// 12 kierunek
}

vector<float>     Data::getWeightedQuery(intvec intQuery){
    vector<float> fQuery;
    cout<<"intQuery size = "<<intQuery.size()<<endl;

    for(int i = 0 ; i < intQuery.size() ; ++i)
        if(weights.size() > i)
            fQuery.push_back(intQuery[i] * weights[i]);


    return fQuery;
}

